package main

import (
	"Gin-Server-01/com/server/core/dao"
	model "Gin-Server-01/com/server/pojo"
	"log"
)

//
//  @Description:框架数据库curd演示
//

func main() {

	db, _ := dao.GetDB()
	admin := model.Admin{
		AId:        12121,
		AEmail:     "1",
		APasswd:    "1",
		APower:     1,
		ALoginCode: "2",
	}

	//添加
	db.Debug().Table("admin").Create(&admin)

	//修改
	db.Debug().Table("admin").Where(model.Admin{AId: 12121}).Find(&admin).Updates(model.Admin{
		AEmail:     "XXXXXX",
		APasswd:    "XXXXXXXXX",
		APower:     90,
		ALoginCode: "JHHSSD",
	})
	//查询
	var adminF model.Admin
	db.Debug().Table("admin").Where(model.Admin{AId: 12121}).Find(&adminF)

	log.Println(adminF)

	//删除
	db.Debug().Table("admin").Where(&model.Admin{AId: 12121}).Delete(&model.Admin{})

}
